home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-23 | 13.8 KB | 283 lines | [TEXT/ttxt] |
- 5 Working with Folders
- This section describes the MacDOS commands which let you
- work with folders. Refer to the section "Data on the Mac"
- for an introduction to the concept of "folder".
-
- Several MacDOS commands operate on folders. To tell MacDOS
- where to look for them, you specify the folder which
- contains them. If you do not specify any containing folder,
- MacDOS operates within what is called the "current folder".
-
- Identifying a Folder
- A folder is identified through its name and its location.
- The name alone is not enough because there could be several
- folders in the system with the same name. The location is
- nothing more than the identification of the folder where
- the folder in question is to be found. This only shifts the
- problem of identification "up" (or "out") one level, but it
- works if you repeat it until you arrive to the top
- (or outermost) folder on the volume. Such a folder is
- unique for each volume and is referred to as "the root" of
- the volume.
-
- To put it more clearly, in order to identify a folder you
- must provide:
- • Identification of the volume where the folder
- resides (ie. the volume ID).
- • The name of all folders, one inside the other, which
- you need to open in order to "reach" the folder you are
- looking for. You start from the outermost folder on the
- volume (ie. the root) which is unique on the volume.
- • The name of the folder itself.
-
- Such an identification in MacDOS looks something like this:
- 1:\fold1\aDeeperFold\still deeper\myFold
- where:
- • "1" is the volume ID.
- • The first backslash stands for the root, which does
- not need to be named because it is unique on the volume.
- • "fold1", "aDeeperFold", and "still deeper" are the
- names of the three folders which are between the root
- and the folder you want to identify. Note that the
- backslashes delimit the names but do not form part of
- them.
- • "myFold" is the name of the folder you are looking
- for.
-
- Folder names are strings of up to 31 characters in length.
- They are not allowed to contain colons, but you should also
- avoid other special characters, as they can create problems
- and confusion. For example, if you include a slash in a
- folder name and then forget to double quote the name when
- you use it in a command, MacDOS will interpret the part
- beginning with the slash as a switch. Moreover, most MacDOS
- commands reject names beginning with a slash whether you
- double quote them or not. For similar reasons, backslashes
- should also be avoided. Also note that if you include a
- semicolon in a folder name, you will not be able to use it
- in the PATH system variable. In general, try to avoid
- characters which are used as separators.
-
- A sequence of folders within folders separated by slashes
- is called a "path". If it starts with a backslash (ie. if
- it includes the root) the path is said to be "absolute",
- otherwise it is "relative". For instance,
- "\fold1\aDeeperFold" is an absolute path, while
- "aDeeperFold\still deeper" is relative.
-
- Fortunately, in most cases you do not need to type the
- volume ID and the whole absolute path. You can direct
- MacDOS to memorise a particular absolute path and never
- have to specify it again until you need to change it. In
- fact, you can tell MacDOS to memorise an absolute path for
- each mounted volume. Such a "default path" for a particular
- volume is called the "current folder" of that volume.
-
- A backslash within a path directs MacDOS to "enter" a
- subfolder. That is, to go one level "down" (or "in"). In
- order to access one of the folders between the root and the
- current folder, you must also be able to tell MacDOS to go
- one level "up" (or "out"). For this purpose, MacDOS accepts
- the fictitious folder name "..": when you type a pair of
- periods (ie. dots) in place of a real folder name, MacDOS
- backtracks one item in the default path. Naturally, this
- means that you should not use ".." to name folders.
-
- Let's bring everything together with some examples:
- • You have two volumes: 1 and 2.
- • The current volume is 1. That is, you are "attached"
- to volume 1.
- • The current folder of volume 1 is "\aaa\bbb" (the
- path which identifies a current folder is always
- absolute).
- • The current folder of volume 2 is its root (ie. the
- default path is just "\").
- Under these circumstances,
- this is equivalent to
- fold 1:\aaa\bbb\fold
- 2:fold 2:\fold
- \fold 1:\fold
- ..\fold 1:\aaa\fold
- ..\bbb\..\bbb\.. 1:\aaa
- ..\.. 1:\
-
- Immediately after launching MacDOS, the default path is set
- to identify the folder which contains the MacDOS
- application file. Therefore, until you direct MacDOS to
- change the current volume or the current folder, your
- commands operate by default on the contents of the folder
- which contains MacDOS itself.
-
- Creating Folders
- You can create a new folder with the command MKDIR (which
- stands for MaKe DIRectory). You can also abbreviate MKDIR
- to MD.
-
- MD accepts a single parameter which specifies the folder to
- be created. For example, you can create a new folder in the
- current folder simply by typing: MD newFolderName.
-
- Removing Folders
- You can remove a folder with the command RMDIR (ReMove
- DIRectory), which can be abbreviated to RD.
-
- Similarly to MD, RD accepts a single parameter which
- specifies the folder. To remove a folder contained in the
- current folder, type: RD oldFolderName.
-
- Note that you can only remove empty folders. The file
- deldir.bat in the original MacDOS floppy is an example of
- how you can remove non-empty folders.
-
- Renaming Folders
- You can change the name of a folder with the command RENDIR
- (REName DIRectory).
-
- RENDIR accepts two parameters, to identify the folder to be
- renamed and to provide the new name.
-
- Listing Folders
- You can list the contents of a folder with two commands:
- DIR and TREE. They both accept a parameter which specifies
- the folder to be listed.
-
- DIR provides the following information on each item (folder
- or file) in the folder:
- • item name;
- • size in bytes if the item is a normal file or volume
- ID of the target if it is an alias;
- • file creator and type if the item is a file;
- • date and time of last update.
- For aliases, DIR displays a second line with information on
- the target. For chains of aliases, DIR displays information
- on the alias in the folder being listed and on the target,
- but not on the intermediate aliases.
- DIR also displays the volume name and the absolute path of
- the folder being listed, as well as the total number of
- bytes occupied.
-
- TREE displays the name of the items in a graphical way, so
- that the hierarchical structure of the folder is
- highlighted.
-
- You can direct both DIR and TREE to select a subset of
- items by extending the parameter to include a wildcarded
- filename. In addition, several switches allow you to select
- what to list:
- • files;
- • folders;
- • files of a certain creator;
- • files of a certain type;
- • hidden files;
- • aliases.
- Through the switch /O, you can also obtain lists in which
- the items are sorted on the basis of their name, size, last
- update, and whether they are folders or files.
-
- Through the switch /S, you can display information on the
- whole hierarchy of folders and files contained in the
- specified folder.
-
- If you "are lost" and would like to find out what the
- current folder is, type CD. You normally use this command
- to change the default folder (see below for a description),
- but without parameter it tells you where you are. Perhaps,
- the best way of always knowing "where you are" is to
- include the option $p in the PROMPT.
-
- Changing the Current Folder
- Immediately after launching MacDOS, the current folder is
- the folder which contains the MacDOS application file. This
- is true regardless of whether you launch MacDOS by double
- clicking on a text file with creator 'mDOS', on an alias of
- MacDOS, or on the application file itself.
-
- You can change the current folder with the command CHDIR
- (CHange DIRectory), which can be abbreviated to CD. CHDIR
- accepts a single parameter which specifies the folder you
- want to make current. If the folder is on a different
- volume, MacDOS automatically attaches to the new volume
- before changing folder.
-
- CHDIR without parameter tells you the current volume and
- folder.
-
- Copying Folder Contents
- You can copy all the items contained in a folder to another
- folder with the command XCOPY. The format of XCOPY is:
- XCOPY sourceFolder destinationFolder
-
- By default, XCOPY only copies the files and does not look
- inside subfolders. To copy everything, so that the
- destination folder is identical to the source both in
- hierarchical structure and contents, use the switch /E.
-
- Other switches let you select files of a particular creator
- or type, or files updated after a certain date.
-
- Note that XCOPY does not make a copy of the folder itself.
- Therefore, if you want to copy a folder with its contents,
- you must first create the destination folder. For example,
- to duplicate the folder aFold, type what follows:
- mkdir "aFold copy"
- xcopy/e aFold "aFold copy"
-
- Special Folders
- The Macintosh Finder gives you the impression that the
- desktop is the base of everything: volumes, folders, and
- files rest on the desktop, and when you move a file from a
- folder window to the desktop you have the impression that
- you are moving it "out". In reality, each volume (eg. a
- floppy) has its own desktop, and desktops are just folders.
-
- Earlier on, you have learnt that each volume has a "root"
- folder which contains everything. If you wanted to give a
- name to the root folder, it would be reasonable to name it
- like the volume itself. Nevertheless, to type the root name
- would be a waste of energy, because it could only appear at
- the beginning of an absolute path. That is why in MacDOS
- (as in DOS) the name is dropped altogether, and the root
- folder is just identified by a backslash on its own.
-
- The Macintosh Finder has implemented a similar strategy:
- when you double click on a volume icon (eg. the icon of a
- floppy), the Finder opens a window which has the same name
- as the volume and shows the contents of the root.
-
- In each root there are two special folders named
- "Desktop Folder" and "Trash". With MacDOS you can see these
- two folders of the startup volume by typing:
- cd 1:\ this attaches you to the root of the
- startup volume;
- dir/a:h this lists the contents of the root
- including hidden items.
-
- The Finder tricks you into believing that there is a single
- desktop by displaying together the contents of the desktop
- folders of all mounted volumes. It does the same with the
- trash can. You do not see these two folders when you open a
- volume window (ie. when you open the root folder by double
- clicking on the volume icon) because the Finder hides them:
- they are there but you cannot see them.
-
- If you insert a floppy and use DIR to list the contents of
- the root, you might find that one or both of these two
- special folders are missing. The reason is that they are
- not automatically created when the floppy is formatted.
- They are only created when they are needed the first time.
-
- One final point needs to be made concerning the issue "one
- desktop per volume": dir "\Desktop Folder" only lists
- what is in the desktop folder of the current volume.
- Similarly, dir \Trash only lists what was trashed from
- the current volume. This way of displaying all desktop and
- trash folders separately might look like a limitation, but
- it gives you more control than the Finder. For example, it
- lets you selectively empty the Trash Can of a particular
- volume (you need a short batch program modelled on the
- example deldir.bat provided in your MacDOS disk). If you
- want to access all the desktop or trash folders together,
- you can always write a small batch program which scans all
- your volumes.
-
-